// var yc = jQuery.noConflict();
var gid=1;
var btxsz=1;
//默认加载一种玩法
//$(window).ready(function(){
	//$.ajaxSetup({cache: false});
	//colers();
	//betnumero();
	//initWanfaAndCastamount();
	//getmessage();
	//$("#new_gonggaoone").load("lotteryBaseinfo.do?method=webnews");
//});
function  initWanfaAndCastamount(){
	$("#wanfaid").attr("value","10101010");
	$.ajax({
	type:'get',
	datatype:'text',
	url:'lotteryBaseinfo.do?method=castamount',
	async:false,
	data:'sortid=10101010',
	success:function(msg){
  	$("#castamount").attr("value",msg);
	}
	});
	initFirstWaiFai();
}
function  initFirstWaiFai(){
 $("#load").load("cqssc/onestar.html");
}
//今日投注
function betnumero(){
	$.ajax({
		type:'get',
		datatype:'json',
		cache:false,
		url:'lotteryBaseinfo.do?method=orderNumero',
		data:'sortid=1010',
		success:function(msg){
			$("#mian_bottomultop>ul li").attr("class","Slider02");
			$("#mian_bottomultop li:eq(2)").attr("class","Slider01");
			var s=msg.split("#");
			$("#mian_bottomultop li:eq(0)").text(s[0].substring(9,12)+"期");
			$("#mian_bottomultop li:eq(0)").attr("title",s[0]);
			$("#mian_bottomultop li:eq(1)").text(s[1].substring(9,12)+"期");
			$("#mian_bottomultop li:eq(1)").attr("title",s[1]);
			$("#mian_bottomultop li:eq(2)").text(s[2].substring(9,12)+"期(当前期)");
			$("#mian_bottomultop li:eq(2)").attr("title",s[2]);
			$("#mian_bottomultop li:eq(3)").text(s[3].substring(9,12)+"期");
			$("#mian_bottomultop li:eq(3)").attr("title",s[3]);
			$("#mian_bottomultop li:eq(4)").text(s[4].substring(9,12)+"期");
			$("#mian_bottomultop li:eq(4)").attr("title",s[4]);
			$("#bettlist").load("lotteryBaseinfo.do?method=tenneworder&type=1010");
		},
		beforeSend:function(){
		//$("#bettlist").html("<img src='images/loading.gif'style='margin-top:50px;' border='0'/>");
		},
		complete:function(){
		},
		error:function(){
		   alert('重庆时时彩当前投注期号获取失败！');
		}
	});
}
//格式化金额并进行四舍五入
function fmoney(s)
{
   n=2;
   s = parseFloat((s + "").replace(/[^\d\.-]/g, "")).toFixed(n) + "";
   var l = s.split(".")[0].split("").reverse(),
   r = s.split(".")[1];
   t = "";
   for(i = 0; i < l.length; i ++ )
   {
      t += l[i];
   }
   return t.split("").reverse().join("") + "." + r;
}
//格式化金额不进行四舍五入
function fmtmoney(oldValue){
	var match = /^(\d+(\.\d\d)?)(\d*)$/; 
	var ok = match.test(oldValue); 
	var newValue = RegExp.$1;
	return newValue;
}
//倍投系数加载
function beitouxishu(obj,th,str){
	btxsz=Number(obj);
	var modl;
	if(Number(btxsz)==1||Number(btxsz)==1.00){
		modl="1";
	}
	if(Number(btxsz)==0.1||Number(btxsz)==0.10){
		modl="2";
	}
	if(Number(btxsz)==0.01){
		modl="3";
	}
	$.post("lotteryBaseinfo.do?method=reSession",{modl:modl});
	$("#dqbtxszhi").text(str);
	$("#shop_right li").removeClass("color");
	$(th).addClass("color");
	$("#main_ml1top>ul>li").attr("class","hcu");
	$("#main_ml1top>ul>li:first-child").attr("class","libg hcu1");
	$("#main_gamenr>ul").hide();
	$("#game1").show();
	var cmots;
	$.ajax({
	type:'post',
	datatype:'text',
	url:'lotteryBaseinfo.do?method=castamount',
	async:false,
	data:'sortid=10101010',
	success:function(msg){
  	cmots=msg;
	}
	});
	loadwanfa("onestar.html",this,"10101010@"+cmots);
	$("#game1 li:first-child").addClass("bg");
	colers();
}

//定时自动局部刷新今日开奖
function getmessage() {
$.ajax({
type:'get',
datatype:'json',
cache:false,
url:'lotteryRankingAndDrawList.do?method=todaynumero&types=dan',
data:'sortid=1010',
success:function(msg){
   $('#bettlist01').html(msg);
},
beforeSend:function(){
   $("#loadingtb").show();
},
complete:function(){
   $('#loadingtb').hide();
},
error:function(){
   alert('重庆时时彩今日开奖数据加载失败！');
}
});
}
$(document).ready(function(){
     //window.setInterval("getmessage()",180000);//刷新今日开奖
     //window.setInterval("betnumero()",180000);//刷新今日投注
});

function bgChange(){
  if(!document.getElementsByTagName) return false;
  var tables = document.getElementsByTagName("table");
  for(var i=0; i<tables.length; i++){
    var odd = false;
    trs = tables[i].getElementsByTagName("tr");
    for(var j=0; j<trs.length; j++){
      if(odd==true){
        trs[j].style.background = "#ffffff";
        odd = false;
      }else{
        odd = true;
      }
    }
  }
}
//遗漏和冷热的切换
function checkradio(){
	var yl=document.getElementById("ylradio");
	var lr=document.getElementById("lrradio");
	if(yl.checked==true){
		$(".lengrezhi").hide();
		$(".yilouzhi").show();
	}
	if(lr.checked==true){
		$(".yilouzhi").hide();
		$(".lengrezhi").show();
	}
}
//大小单双遗漏和冷热的切换
function checkradio2(){
	var yl=document.getElementById("dxylradio");
	var lr=document.getElementById("dxlrradio");
	if(yl.checked==true){
		$(".daxiaolengrezhi").hide();
		$(".daxiaoyilouzhi").show();
	}
	if(lr.checked==true){
		$(".daxiaoyilouzhi").hide();
		$(".daxiaolengrezhi").show();
	}
}
//组选三的单复式切换
function checkradio3(){
	var ds=document.getElementById("zuxuansandanshi");
	var fs=document.getElementById("zuxuansanfushi");
	if(ds.checked==true){
		$("#main_bd1").hide();
		$("#main_bd2").show();
	}
	if(fs.checked==true){
		$("#main_bd2").hide();
		$("#main_bd1").show();
	}
}
//追号初始值
function zhuihaoInti(){
	var cumult=$("#customize_mult").val();
	$("#winning_stop").val(1);
	$("#abandoning").val(1);
	$("#zjhtz").attr("checked",true);
	$("#chhfq").attr("checked",true);
	$("#main_ml3").show();
//	$("#main_ml4").hide();
	$("#tzdeatil").show();
	$("#chase").val("1");
	//计算总金额
	var valus=$("#betting_slip").val();
	var stri=valus.split("@");
	var zje=0;
	for(k=1;k<stri.length;k++){
		var stra=stri[k].split(",");
		zje=Number(zje)+Number(stra[3]);
	}
	//初始化追号期数
	$("#objectissuetextinput").val(1);
	//清楚以前的子节点
	$("#zhuihaolist").empty();
	//动态生成一个select下拉菜单
	$.post("lotteryBaseinfo.do?method=ocurentdate&sortid=1010",function(data){
		var dateobj=data.substring(0,8);
		$("#dangdate").val(dateobj);
		var str=data.substring(9,data.length);
		$("#issuedate").val(str);
		$("#danqi").val(str);
		$("#CountIssue1").text(121-Number(str));
		var selector=$("<select id=\"sel\" onchange=\"changers(this.value);\"></select>");
		for(var i=Number(str);i<121;i++){
			var vl;
			if(i>=1&&i<10){vl="00"+i;}
			if(i>=10&&i<100){vl="0"+i;}
			if(i>=100){vl=i;}
			if(i==Number(str)){
				selector.append("<option value=\""+vl+"\" selected>"+dateobj+"-"+vl+"[当前期]</option>");
			}else{
		    	selector.append("<option value=\""+vl+"\" >"+dateobj+"-"+vl+"期</option>");
		    }
		}
		$("#zhbegindate").html(selector);
		if(cumult=='1'||cumult==1){
			$("#zhuihaolist").append("<ul class=\"bg_yellow\"><li class=\"liwidth1\">"+str+"[当前期]</li><li class=\"liwidth\"><input id=\"zhbeishu_0\" type=\"text\" maxlength=\"5\" size=\"8\" value=\"1\" onkeyup=\"zhuihaobeitou(this.value,0,"+fmoney(zje)+");\" onclick=\"javascript:this.focus();this.select();\"/></li><li class=\"liwidth\">￥<span id=\"zhuihaotouru_0\">"+fmoney(zje)+"</span></li><li class=\"liwidth\">￥<span id=\"leijitouru_0\">"+fmoney((Number(zje)*1))+"</span></li><li class=\"liwidth\"></li><li class=\"liwidth\"></li></ul>");
		}
		var dbzzs=$("#danbeizongzhushu").text();
		var qishu=$("#objectissuetextinput").val();
		//追号总注数
		$("#zhzzs").text(dbzzs);
		//所追期数
		$("#zhzqs").text(qishu);
		//需要投入金额
		$("#zhzje").text(fmoney(Number(zje)*1));
	});
	
	
}
//倍投工具与自定义的切换
$("input[name='MenuMutiply']").click(function(){
	var value=$(this).val();
	if(value=='1'||value==1){
		$("#customize_mult").val("1");
		zhuihaoInti();
		$("#mult_tools").hide();
		$("#investment").hide();
		$("#mainm_ml3").show();
	}else if(value=='2'||value==2){
		$("#program_list").empty();
		$("#customize_mult").val("2");
		zhuihaoInti();
		$("#mult_tools").show();
		$("#investment").show();
		$("#mainm_ml3").hide();
		$("#multcount").val(1);
		$("#bcount").val("");
	}
});
//是否追号

//计算追号列表的每行倍投后的投入金额以及累计投入
function zhuihaobeitou(vals,nos,zje){
	var regu = /^[0-9]{1,}$/;
	var qishu=$("#objectissuetextinput").val();
	if(regu.test(vals)&&Number(vals)>=1){
		if(Number(nos+1)==qishu){
			if(Number(nos)==0){
				$("#zhuihaotouru_"+nos).text(fmoney(Number(zje*vals)));
				$("#leijitouru_"+nos).text(fmoney(Number(zje*vals)));
			}else if(Number(nos)>0){
				var upleitou=$("#leijitouru_"+Number(nos-1)).text();
				$("#zhuihaotouru_"+nos).text(fmoney(Number(zje*vals)));
				$("#leijitouru_"+nos).text(fmoney((Number(zje*vals)+Number(upleitou))));
			}
		}else{
			for(var i=nos;i<qishu;i++){
				$("#zhbeishu_"+i).val(vals);
				if(Number(i)==0){
					$("#zhuihaotouru_"+i).text(fmoney(Number(zje*vals)));
					$("#leijitouru_"+i).text(fmoney(Number(zje*vals)));
				}else if(Number(i)!=0){
					var upleitou=$("#leijitouru_"+Number(i-1)).text();
					$("#zhuihaotouru_"+i).text(fmoney(Number(zje*vals)));
					$("#leijitouru_"+i).text(fmoney((Number(zje*vals)+Number(upleitou))));
				}
			}
		}
	}else{
		$("#zhbeishu_"+nos).val(1);
		alert("只能输入数字,并且此数字大于1");
	}
	var zsse=$("#leijitouru_"+Number(qishu-1)).text();
	$("#zhzje").text(fmoney(zsse));
}
//追号期数的验证及计算
$("#objectissuetextinput").keyup(function(evt){
	var cmult=$("#customize_mult").val();
	if(cmult=='1'||cmult==1){
		var x = (window.event||evt).keyCode;
		//计算总金额
		var valus=$("#betting_slip").val();
		var stri=valus.split("@");
		var zje=0;
		for(k=1;k<stri.length;k++){
			var stra=stri[k].split(",");
			zje=Number(zje)+Number(stra[3]);
		}
		//清空子节点
		$("#zhuihaolist").empty();
		var dbzzs=$("#danbeizongzhushu").text();
		//所追期数
		var qishu=$("#objectissuetextinput").val();
		//得到当前期号
		var danqi=$("#danqi").val();
		//得到当前日期
		var dangdate=$("#dangdate").val();
		var regu = /^[0-9]{1,}$/;
		//追号的起始期
		var dats=$("#issuedate").val();
		if(regu.test(qishu)){
	  	if((x>=48&&x<=57)||(x>=0x60&&x<=0x69)||(x==8)){
			if(qishu==0||qishu=="0"){
				$("#objectissuetextinput").val(1);
				$("#zhuihaolist").append("<ul class=\"bg_yellow\"><li class=\"liwidth1\">"+(danqi==dats?"":dangdate+"-")+dats+(danqi==dats?"[当前期]":"期")+"</li><li class=\"liwidth\"><input id=\"zhbeishu_0\" type=\"text\" size=\"8\" maxlength=\"5\" value=\"1\" onkeyup=\"zhuihaobeitou(this.value,0,"+zje+");\" onclick=\"javascript:this.focus();this.select();\"/></li><li class=\"liwidth\">￥<span id=\"zhuihaotouru_0\">"+fmoney(zje)+"</span></li><li class=\"liwidth\">￥<span id=\"leijitouru_0\">"+fmoney((Number(zje)*1))+"</span></li><li class=\"liwidth\"></li><li class=\"liwidth\"></li></ul>");
				//追号总注数
				$("#zhzzs").text(dbzzs);
				//所追期数
				$("#zhzqs").text(1);
				//需要投入金额
				$("#zhzje").text(fmoney(Number(zje)*1));
			}
			if(qishu!=0||qishu!="0"){
				if((Number(qishu)+Number(dats))>121){
					alert("从所选期开始,你最多只能追"+(121-Number(dats))+"!");
					$("#objectissuetextinput").focus();
					$("#objectissuetextinput").select();
				}else{
					//追号总注数
					$("#zhzzs").text(dbzzs);
					//所追期数
					$("#zhzqs").text(qishu);
					for(var l=0;l<qishu;l++){
						var vl;
						if((Number(dats)+l)>=1&&(Number(dats)+l)<10){vl="00"+(Number(dats)+l);}
						if((Number(dats)+l)>=10&&(Number(dats)+l)<100){vl="0"+(Number(dats)+l);}
						if((Number(dats)+l)>=100){vl=(Number(dats)+l);}
						$("#zhuihaolist").append("<ul class=\"bg_yellow\"><li class=\"liwidth1\">"+(danqi==vl?"":dangdate+"-")+vl+(danqi==vl?"[当前期]":"期")+"</li><li class=\"liwidth\"><input id=\"zhbeishu_"+l+"\" type=\"text\" maxlength=\"5\" size=\"8\" value=\"1\" onkeyup=\"zhuihaobeitou(this.value,"+l+","+fmoney(zje)+");\" onclick=\"javascript:this.focus();this.select();\"/></li><li class=\"liwidth\">￥<span id=\"zhuihaotouru_"+l+"\">"+fmoney(zje)+"</span></li><li class=\"liwidth\">￥<span id=\"leijitouru_"+l+"\">"+fmoney((Number(zje)*(l+1)))+"</span></li><li class=\"liwidth\"></li><li class=\"liwidth\"></li></ul>");
						//需要投入金额
						$("#zhzje").text(fmoney(Number(zje)*(l+1)));
					}
				}
			}
		}
		}else{
			$("#objectissuetextinput").val(1);
			$("#zhuihaolist").append("<ul class=\"bg_yellow\"><li class=\"liwidth1\">"+(danqi==dats?"":dangdate+"-")+dats+(danqi==dats?"[当前期]":"期")+"</li><li class=\"liwidth\"><input id=\"zhbeishu_0\" type=\"text\" size=\"8\" maxlength=\"5\" value=\"1\" onkeyup=\"zhuihaobeitou(this.value,0,"+fmoney(zje)+");\" onclick=\"javascript:this.focus();this.select();\"/></li><li class=\"liwidth\">￥<span id=\"zhuihaotouru_0\">"+fmoney(zje)+"</span></li><li class=\"liwidth\">￥<span id=\"leijitouru_0\">"+fmoney((Number(zje)*1))+"</span></li><li class=\"liwidth\"></li><li class=\"liwidth\"></li></ul>");
			//追号总注数
			$("#zhzzs").text(dbzzs);
			//所追期数
			$("#zhzqs").text(1);
			//需要投入金额
			$("#zhzje").text(fmoney(Number(zje)*1));
			alert("只能输入数字,并且此数字大于1");
		}
	}
});
function changers(vals){
	//计算总金额
	var valus=$("#betting_slip").val();
	var stri=valus.split("@");
	var zje=0;
	for(k=1;k<stri.length;k++){
		var stra=stri[k].split(",");
		zje=Number(zje)+Number(stra[3]);
	}
	//得到当前期号
	var danqi=$("#danqi").val();
	//得到当前日期
	var dangdate=$("#dangdate").val();
	$("#issuedate").val(vals);
	$("#CountIssue1").text(121-Number(vals));
	//清空子节点
	$("#zhuihaolist").empty();
	var dbzzs=$("#danbeizongzhushu").text();
	var qishu=$("#objectissuetextinput").val();
	if(vals=="120"){
		$("#objectissuetextinput").val(1);
		$("#zhuihaolist").append("<ul class=\"bg_yellow\"><li class=\"liwidth1\">"+(danqi==vals?"":dangdate+"-")+vals+(danqi==vals?"[当前期]":"期")+"</li><li class=\"liwidth\"><input id=\"zhbeishu_0\" type=\"text\" size=\"8\" maxlength=\"5\" value=\"1\" onkeyup=\"zhuihaobeitou(this.value,0,"+fmoney(zje)+");\" onclick=\"javascript:this.focus();this.select();\"/></li><li class=\"liwidth\">￥<span id=\"zhuihaotouru_0\">"+fmoney(zje)+"</span></li><li class=\"liwidth\">￥<span id=\"leijitouru_0\">"+fmoney((Number(zje)*1))+"</span></li><li class=\"liwidth\"></li><li class=\"liwidth\"></li></ul>");
		//追号总注数
		$("#zhzzs").text(dbzzs);
		//所追期数
		$("#zhzqs").text(1);
		//需要投入金额
		$("#zhzje").text(fmoney(Number(zje)*1));
	}else if((Number(qishu)+Number(vals))>121){
					alert("从所选期开始,你最多只能追"+(121-Number(vals))+"!");
					$("#objectissuetextinput").focus();
					$("#objectissuetextinput").select();
					$("#objectissuetextinput").val(121-Number(vals));
					$("#zhzzs").text(dbzzs);
					//所追期数
					$("#zhzqs").text(1);
					for(var l=0;l<(120-Number(vals));l++){
						var vl;
						if((Number(vals)+l)>=1&&(Number(vals)+l)<10){vl="00"+(Number(vals)+l);}
						if((Number(vals)+l)>=10&&(Number(vals)+l)<100){vl="0"+(Number(vals)+l);}
						if((Number(vals)+l)>=100){vl=(Number(vals)+l);}
						$("#zhuihaolist").append("<ul class=\"bg_yellow\"><li class=\"liwidth1\">"+(danqi==vl?"":dangdate+"-")+vl+(danqi==vl?"[当前期]":"期")+"</li><li class=\"liwidth\"><input id=\"zhbeishu_"+l+"\" type=\"text\" maxlength=\"5\" size=\"8\" value=\"1\" onkeyup=\"zhuihaobeitou(this.value,"+l+","+fmoney(zje)+");\" onclick=\"javascript:this.focus();this.select();\"/></li><li class=\"liwidth\">￥<span id=\"zhuihaotouru_"+l+"\">"+fmoney(zje)+"</span></li><li class=\"liwidth\">￥<span id=\"leijitouru_"+l+"\">"+(Number(zje)*(l+1))+"</span>.00</li><li class=\"liwidth\"></li><li class=\"liwidth\"></li></ul>");
						//需要投入金额
						$("#zhzje").text(fmoney(Number(zje)*(l+1)));
					}
		}else{
			//追号总注数
			$("#zhzzs").text(dbzzs);
			//所追期数
			$("#zhzqs").text(qishu);
			for(var l=0;l<qishu;l++){
				var vl;
				if((Number(vals)+l)>=1&&(Number(vals)+l)<10){vl="00"+(Number(vals)+l);}
				if((Number(vals)+l)>=10&&(Number(vals)+l)<100){vl="0"+(Number(vals)+l);}
				if((Number(vals)+l)>=100){vl=(Number(vals)+l);}
				$("#zhuihaolist").append("<ul class=\"bg_yellow\"><li class=\"liwidth1\">"+(danqi==vl?"":dangdate+"-")+vl+(danqi==vl?"[当前期]":"期")+"</li><li class=\"liwidth\"><input id=\"zhbeishu_"+l+"\" type=\"text\" size=\"8\" maxlength=\"5\" value=\"1\" onkeyup=\"zhuihaobeitou(this.value,"+l+","+fmoney(zje)+");\" onclick=\"javascript:this.focus();this.select();\"/></li><li class=\"liwidth\">￥<span id=\"zhuihaotouru_"+l+"\">"+fmoney(zje)+"</span></li><li class=\"liwidth\">￥<span id=\"leijitouru_"+l+"\">"+fmoney((Number(zje)*(l+1)))+"</span></li><li class=\"liwidth\"></li><li class=\"liwidth\"></li></ul>");
				//需要投入金额
				$("#zhzje").text(fmoney(Number(zje)*(l+1)));
			}
	}
}
//生成订单
$("#betting_enter").click(function(){
	var $token = $("#token").val();
	$("#token").val("1");
	$("#betting_enter").css("background-position","-392px -161px");
	if ($token == "0") {
		var rname=$("#rname").val();
			if (rname==""||rname==null) {
				alert("游客不能进行投注,请先登录后再进行投注！");
				$("#token").val("0");
				$("#betting_enter").css("background-position","-268px -161px");
			}else {
				myOrder(rname);
			}
	}
});


//生成订单
$("#yesbet").click(function(){
	var $token = $("#token").val();
	$("#token").val("1");
	//$("#yesbet").css("background-position","-392px -161px");
	if ($token == "0") {
		var rname=$("#rname").val();
			if (rname==""||rname==null) {
				alert("游客不能进行投注,请先登录后再进行投注！");
				$("#token").val("0");
				//$("#betting_enter").css("background-position","-268px -161px");
			}else {
				myOrder(rname);
				hideDiv('main_ml3');
	//			colers();
			}
	}
});
function myOrder(rname){
				//起始期号
				var begindate = $("#issuedate").val();
				//所追期数
				var zhuihaoshu = $("#objectissuetextinput").val();
				//当前日期
				var dangdate = $("#dangdate").val();
				//var sfchase=$("#chase").attr("checked");
				var beishu = "";
				var cozmult=$("#customize_mult").val();
				if(cozmult=='1'||cozmult==1){
					for (var l = 0; l < zhuihaoshu; l++) {
						var s = $("#zhbeishu_" + l).val();
						beishu = beishu + "_" + s;
					}
				}else{
					beishu=$("#bcount").val();
				}
				var uname = rname;
				var betting_slip = $("#betting_slip").val();
				var moshi = escape($("#dqbtxszhi").text());
				var seriesname=escape($("#seriesname").val());
				//var date_number="20091128-25";
				var sortid = "1010";
				var chase_chk = $("#chase").val();
				var multiples = $("#multiples").val();
				var chase_slip = dangdate + "-" + begindate + "," + zhuihaoshu + "," + beishu.substring(1, beishu.length);
				var winning_stop = $("#winning_stop").val();
				var abandoning = $("#abandoning").val();
				var dgmot = $("#danqigoumainot").val();
				var sid=$("#sid").val();
				var nownumero = $("#nowdatenumers").text();
				if (betting_slip.length <= 0) {
					alert("请先正确选择号码后再投注！");
					$("#token").val("0");
					$("#betting_enter").css("background-position","-268px -161px");
				}else if (Number(dgmot) == 0) {
						alert("当前第" + nownumero + "期投注时间已结束！");
						$("#token").val("0");
						$("#betting_enter").css("background-position","-268px -161px");
					}else {
						betting_slip = betting_slip.substring(1, betting_slip.length);
						var bett=betting_slip.split("@");
						if(bett.length>2000){
							alert("投注的总注数不能超过2000注!谢谢合作!");
						}else{
							var bettslip="";
							for(var i=0;i<bett.length;i++){
								var k=bett[i].split(",");
								bettslip=bettslip+"@"+k[0]+","+k[1];
							}
							betting_slip = bettslip.substring(1, bettslip.length);
							var sfzh = (chase_chk == 0 ? "否" : "是");
							var zzs = $("#danbeizongzhushu").text();
							var zje;
							var bsys;
							if (chase_chk == 0) {
								zje = $("#danbeizongjine").text();
								bsys = "倍    数：" + multiples + "倍\n";
							}else {
								if(cozmult=='1'||cozmult==1){
									zje = $("#leijitouru_" + Number(zhuihaoshu - 1)).text();
									bsys = "所追期数：" + zhuihaoshu + "期\n";
								}else{
									zje = $("#acccount").val();
									var bc=beishu.split("_");
									bsys = "所追期数：" + (Number(bc.length)-1) + "期\n";
								}
							}
							var falg = window.confirm("请确认以下信息,如无误后请点击确定按钮！\n" +
							"---------------------------------\n" +
							"是否追号：" +sfzh +"\n"
							+"单倍注数：" +zzs +"注\n"
							+"总 金 额：￥" +fmoney(zje)+"\n"
							+bsys +
							"---------------------------------\n");
							if (falg) {
								$.post("lotteryOrder.do?method=addLotteryOrder", {
									betting_slip: betting_slip,
									chase_chk: chase_chk,
									chase_slip: chase_slip,
									multiples: multiples,
									winning_stop: winning_stop,
									abandoning: abandoning,
									kindname: moshi,
									sortid: sortid
								}, function(obj){
									if (obj == "err1") {
										alert("当前不允许投注！");
										colers();
										$("#token").val("0");
										$("#betting_enter").css("background-position","-268px -161px");
									}
									else
										if (obj == "err2") {
											alert("投注金额大于封所金额!");
											colers();
											$("#token").val("0");
											$("#betting_enter").css("background-position","-268px -161px");
										}
										else
											if (obj == "err3") {
												alert("投注金额大于个人余额!");
												colers();
												$("#token").val("0");
												$("#betting_enter").css("background-position","-268px -161px");
											}
											else
												if (obj == "err4") {
													alert("帐户余额为负,不能购买投注单!");
													colers();
													$("#token").val("0");
													$("#betting_enter").css("background-position","-268px -161px");
												}
												else
													if (obj == "err5") {
														alert("登录用户名错误!");
														colers();
														$("#token").val("0");
														$("#betting_enter").css("background-position","-268px -161px");
													}
													else {
														var str = obj.split("@");
														if (str[0] == "err6") {
															alert(str[1]);
															colers();
															$("#token").val("0");
															$("#betting_enter").css("background-position","-268px -161px");
														}
														if (str[0] == "err0") {
															alert(str[1]);
															colers();
															$("#token").val("0");
															$("#betting_enter").css("background-position","-268px -161px");
														}
														if (str[0] == "err7") {
															alert("生成订单成功!\n" +
															"----------------------------------\n" +
															"订单编号：" +str[2] +"\n" +
															"投注期号：" +str[3] +"\n" +
															"投注总额：￥" +fmoney(zje)+"\n" +
															"----------------------------------\n");
															colers();
															$("#token").val("0");
															$("#betting_enter").css("background-position","-268px -161px");
															betnumero();
															showMoney();
														}
													}
								});
							}else{
							$("#token").val("0");
							$("#betting_enter").css("background-position","-268px -161px");
							}
						}
					}
			}
//验证单倍注数的输入并计算出金额
$("#multiples").keyup(function(evt){
	var x = (window.event||evt).keyCode;
	var beis=$("#multiples").val();
	var regu = /^[0-9]{1,}$/;
	var je=$("#zjines").val();
	if(regu.test(beis)){
		  	if((x>=48&&x<=57)||(x>=0x60&&x<=0x69)||(x==8)){
				if(beis==0||beis=="0"){
					$("#multiples").val(1);
					$("#danbeizongjine").text(fmoney(1*je));
				}
				if(beis!=0||beis!="0"){
					$("#danbeizongjine").text(fmoney(beis*je));
				}
			}
	}else{
		$("#multiples").val(1);
		$("#danbeizongjine").text(fmoney(1*je));
		alert("只能输入数字,并且此数字大于1");
	}
});

//删除选择的号码单
function delUl(str,obj){
   var bs=$("#multiples").val();
	$(str).parent().remove();
	var betting_slip=$("#betting_slip").val();
	var st=betting_slip.replace(obj,"");
	$("#betting_slip").val(st);
	//计算投注项中的总注数以及金额
	var valus=$("#betting_slip").val();
	var stri=valus.split("@");
	var sumzs=0;
	var sumjne=0;
	for(k=1;k<stri.length;k++){
		var stra=stri[k].split(",");
		sumzs=Number(sumzs)+Number(stra[2]);
		sumjne=Number(sumjne)+Number(stra[3]);
	}
	//并把计算出来的总注数和金额设置到页面中显示
	$("#danbeizongzhushu").text(sumzs);
	$("#danbeizongjine").text(fmoney(Number(sumjne*bs)));
	$("#zjines").val(fmoney(Number(sumjne*bs)));
	sxzhuihao(sumzs,fmoney(Number(sumjne*bs)));
}
//清空变量值
function colers(){
	$("#mainm_ml2r").children().remove();
	$("#betting_slip").val("");
	$("#multiples").val(1);
	gid=1;
	//清空子节点
	$("#zhuihaolist").empty();
	$("#main_ml3").hide();
	$("#main_ml4").show();
	$("#tzdeatil").hide();
	$("#chase").val("0");
	$("#chase").attr("checked",false);
	$("#danbeizongzhushu").text("0");
	$("#danbeizongjine").text("0.00");
	$("#zjines").val("");
	$("#yuecke").attr("checked",false);
	//$("#yues").text("******");
	$("#multcount").val(1);
	$("#program_list").empty();
	$("#bcount").val("");
}
$("#cleartzx").click(function(){
colers();
});
//刷新追号列表
function sxzhuihao(zs,je){
	var ob=$("#chase").attr("checked");
	if(ob){
		//判断倍投工具是否可用
		var bets=$("#betting_slip").val();
		var bes=bets.split("@");
		if((bes.length-1)==1){
			$("#MenuMutiply2").attr("disabled",false);
		}else{
			$("#MenuMutiply2").attr("disabled",true);
		}
		//清空子节点
		$("#zhuihaolist").empty();
		var zje=fmoney(je);
		var dbzzs=zs;
		//所追期数
		var qishu=$("#objectissuetextinput").val();
		//得到当前期号
		var danqi=$("#danqi").val();
		//得到当前日期
		var dangdate=$("#dangdate").val();
		//追号的起始期
		var dats=$("#issuedate").val();
		//追号总注数
		$("#zhzzs").text(dbzzs);
		//所追期数
		$("#zhzqs").text(qishu);
		for(var l=0;l<qishu;l++){
			var vl;
			if((Number(dats)+l)>=1&&(Number(dats)+l)<10){vl="00"+(Number(dats)+l);}
			if((Number(dats)+l)>=10&&(Number(dats)+l)<100){vl="0"+(Number(dats)+l);}
			if((Number(dats)+l)>=100){vl=(Number(dats)+l);}
			$("#zhuihaolist").append("<ul class=\"bg_yellow\"><li class=\"liwidth1\">"+(danqi==vl?"":dangdate+"-")+vl+(danqi==vl?"[当前期]":"期")+"</li><li class=\"liwidth\"><input id=\"zhbeishu_"+l+"\" type=\"text\" size=\"8\" maxlength=\"5\" value=\"1\" onkeyup=\"zhuihaobeitou(this.value,"+l+","+fmoney(zje)+");\" onclick=\"javascript:this.focus();this.select();\"/></li><li class=\"liwidth\">￥<span id=\"zhuihaotouru_"+l+"\">"+fmoney(zje)+"</span></li><li class=\"liwidth\">￥<span id=\"leijitouru_"+l+"\">"+fmoney((Number(zje)*(l+1)))+"</span></li></ul>");
			//需要投入金额
			$("#zhzje").text(fmoney(Number(zje)*(l+1)));
		}
		
	}
}
//中奖后停止的选择
$("#zjhtz").click(function(){
	var obj=$(this).attr("checked");
	if(obj){
		$("#winning_stop").val(1);
	}else{
		$("#abandoning").val(0);
		$("#winning_stop").val(0);
		$("#chhfq").attr("checked",false);
	}
});
//出号即放弃
$("#chhfq").click(function(){
	var obj=$(this).attr("checked");
	if(obj){
		$("#abandoning").val(1);
		$("#winning_stop").val(1);
		$("#zjhtz").attr("checked",true);
	}else{
		$("#abandoning").val(0);
	}
});
//筛选鼠标放上
function sxmover(obj){
	$(obj).find(".shuaixuancaidan").show();
}
//筛选鼠标离开
function sxmout(obj){
	$(obj).find(".shuaixuancaidan").hide();
}
//筛选鼠标放上
function sxmoverone(){
	$("#shuaixuancaidanone").show();
}
//筛选鼠标离开
function sxmoutone(){
	$("#shuaixuancaidanone").hide();
}

//筛选鼠标放上
function sxmovertwo(){
	$("#shuaixuancaidantwo").show();
}
//筛选鼠标离开
function sxmouttwo(){
	$("#shuaixuancaidantwo").hide();
}

//筛选鼠标放上
function sxmoverthree(){
	$("#shuaixuancaidanthree").show();
}
//筛选鼠标离开
function sxmoutthree(){
	$("#shuaixuancaidanthree").hide();
}

//筛选鼠标放上
function sxmoverfour(){
	$("#shuaixuancaidanfour").show();
}
//筛选鼠标离开
function sxmoutfour(){
	$("#shuaixuancaidanfour").hide();
}
$(document).ready(function(){
    //$("input").bind("contextmenu",function(e){
      //  return false;
   //});
});
function handwork(){
	$("#mainm_ml2l").html("<img src='images/loading.gif' border='0' style='margin-top:90px;margin-left:210px;'/>");
	$("#mainm_ml2l").load("cqssc/handwork.html");
}
function sxhandwork(){
	$("#mainm_ml2l").html("<img src='images/loading.gif' border='0' style='margin-top:90px;margin-left:210px;'/>");
	$("#mainm_ml2l").load("cqssc/handinput.html");
}
function frsxhandwork(){
	$("#mainm_ml2l").html("<img src='images/loading.gif' border='0' style='margin-top:90px;margin-left:210px;'/>");
	$("#mainm_ml2l").load("cqssc/front_handinput.html");
}
function goback(){
	$("#load").html("<div id='main_ml2l'><div id='maint_ml2l'></div><div id='mainm_ml2l' style='line-height:324px; text-align:center;' ><img src='images/loading.gif' border='0' style='margin-top:90px;'/></div> <div id='mainb_ml2l'></div></div>");
	var filename=$("#filename").val();
	$("#load").load("cqssc/"+filename);
}
function copyToClipboard(txt) {    
    if(window.clipboardData){
    	window.clipboardData.clearData();
    	window.clipboardData.setData("Text", txt);
    }else if(navigator.userAgent.indexOf("Opera")!= -1){
    	window.location = txt;
    }else if(window.netscape){
    	try {
    		netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
    	}catch(e){
    		alert("被浏览器拒绝！\n请在浏览器地址栏输入'about:config'并回车\n然后将'signed.applets.codebase_principal_support'设置为'true'");
    	}    
    var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);    
    if (!clip){return;}
    var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
    if (!trans){return;}
    trans.addDataFlavor('text/unicode');
    var str = new Object();
    var len = new Object();
    var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
    var copytext = txt;
    str.data = copytext;
    trans.setTransferData("text/unicode",str,copytext.length*2);
    var clipid = Components.interfaces.nsIClipboard;    
    if (!clip){return false;}
    clip.setData(trans,null,clipid.kGlobalClipboard);
    }    
}